<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <h1>{{title}}</h1>
        <m-head></m-head>
        <parent msg="火大,非常火大" idx="666" :word="word" user-name="peiqi" :hobby="arr"></parent>
    </div>


    <template id="parent">
        <div>
            <h2>parent-parent 组件</h2>
            <p>hello components</p>
            <h4>props ---{{msg}}---{{idx}}---{{word}} ---{{userName}}---{{hobby}}</h4>
            <button @click="++idx">change idx</button>
            <hr>
            <child-one :address="address" :flag="flag" a="are you ok?" :like="list" :man="person"></child-one>
        </div>
    </template>

    <template id="childOne">
        <div>
            <h2>childOne 子组件</h2>
            <h2>address --- {{address}}---{{flag}}---{{a}}</h2>
            <p>---{{like}}</p>
            <p>----------{{man}}</p>

        </div>
    </template>

</body>
<script>

    Vue.component("mHead", {
        template: "<header>wuhan2105-daydayup</header>"
    })

    Vue.component("parent", {
        template: "#parent",
        // 简单接收方法 数组写法
        props: ["msg", "idx", "word", "userName", "hobby"], /* this,msg获取 */
        data() {
            return {
                address: "这是个什么鬼呢",
                flag: !!false,
                list: [
                    "爱这个", "爱那个", "还爱那个"
                ],
                person: {
                    name: "Zhao Ritian",
                    age: "100",
                }
            }
        }
    })

    Vue.component("childOne", {
        template: "#childOne",
        // 对象格式  可校验
        props: {
            address: String, /* 校验数据 */
            flag: {
                type: Boolean, /* 要求传参布尔值 如果不传参 默认为true */
                default: true,
            },
            a: String,
            like: {
                type: Array,

            },
            man: Object,
        }
    })

    const vm = new Vue({
        // 局部组件注册

        data: {
            title: "Vue 组件属性 props",
            word: "Vue 学不会",
            arr: ["code", "work", "don't like the work", "so change work"]
        },

    }).$mount("#app")
</script>

</html>